﻿using UnityEngine;

public class TriggerArea : MonoBehaviour
{
    protected virtual bool IsTarget(Collider2D collider)
        => collider.CompareTag("Player"); 

    protected void OnTriggerEnter2D(Collider2D collider)
    {
        if (IsTarget(collider))
            OnEnter(collider);
    }
    protected void OnTriggerExit2D(Collider2D collider)
    {
        if (IsTarget(collider))
            OnExit(collider);
    }
    protected void OnTriggerStay2D(Collider2D collider)
    {
        if (IsTarget(collider))
            OnStay(collider);
    }

    protected virtual void OnEnter(Collider2D collider) { }
    protected virtual void OnExit(Collider2D collider) { }
    protected virtual void OnStay(Collider2D collider) { }
}
